import 'package:flutterapp/common/constant/api.dart';
import 'package:flutterapp/http/http_utils.dart';
import 'package:flutterapp/item/entity/item_list_entity.dart';
import 'package:flutterapp/item/entity/item_tree_entity.dart';
import 'package:flutterapp/item/service/item_service.dart';

class ItemServiceImpl extends ItemService {
  static ItemServiceImpl? _instance;

  static ItemServiceImpl getInstance() {
    if (_instance == null) _instance = ItemServiceImpl();
    return _instance!;
  }

  @override
  Future<ItemListEntity?> getItemListByCid(int pageNum, int cid) async {
    return HttpUtils.getInstance()
        .get<ItemListEntity>(API.getItemList(pageNum, cid), isNeedCache: true);
  }

  @override
  Future<ItemTreeEntity?> getItemTree() {
    return HttpUtils.getInstance()
        .get<ItemTreeEntity>(API.itemTree, isNeedCache: true);
  }
}
